/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package editor;

import java.awt.Choice;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JButton;
import javax.swing.JFrame;


/**
 *
 * @author emmanuel
 */
public abstract class GLDToolBar extends ToolBar implements ActionListener, ItemListener
{
	protected static final int NEW = 1;
	protected static final int OPEN = 2;
	protected static final int SAVE = 3;
	protected static final int CENTER = 4;
	protected static final int SCROLL = 5;
	protected static final int ZOOM = 6;
	protected static final int SELECT = 7;
	protected static final int EDGENODE = 9;
	protected static final int CONFIG = 10;
	
	protected static final int APPBUTTON = 100;
	
	protected static final int HELP = 911;

	protected JFrame controller;
	
	protected Choice zoom;
	
	public GLDToolBar(JFrame c, boolean newicon) {
		super();
		controller = c;


		if (newicon) addButton("/images/new.gif", this, NEW);
		addButton("/images/open.gif", this, OPEN);
		addButton("/images/save.gif", this, SAVE);
		
		addSeparator();

    zoom = new Choice();
    zoom.add("25%");
    zoom.add("50%");
    zoom.add("75%");
    zoom.add("100%");
    zoom.add("150%");
    zoom.add("200%");
    zoom.add("250%");
    zoom.addItemListener(this);
    zoom.setSize(75, 15);
    zoom.select(3);
    addComponent(zoom);
    
    addSeparator();
    addButton("/images/center.gif", this, CENTER);
		addSeparator();

  	addButton("/images/scroll.gif", this, SCROLL);
  	addButton("/images/zoom.gif", this, ZOOM);
  	addButton("/images/select.gif", this, SELECT);
  	
  	addSeparator();

		addTools();

  	addSeparator();
  	
  	addButton("/images/config.gif", this, CONFIG);
  	
  	addSeparator();
  	
		addButton("/images/help.gif", this, HELP);
		
		addSeparator();
	}
	
	protected abstract void addTools();
	
	public Choice getZoom() { return zoom; }
	
	public void actionPerformed(ActionEvent e) {
		//String Id = ((JButton)e.getSource()).getActionCommand();
                //if(Id.equals("New"))
		/*switch (Id) {
			case NEW      : { controller.newFile(); break; }
			case OPEN     : { controller.openFile(); break; }
			case SAVE     : { controller.saveFile(); break; }
			case CENTER   : { controller.getViewScroller().center(); break; }
			case SCROLL   : { controller.changeTool(new ScrollTool(controller)); break; }
			case ZOOM     : { controller.changeTool(new ZoomTool(controller)); break; }
			case SELECT   : { controller.changeTool(new SelectTool(controller)); break; }
			case EDGENODE : { controller.changeTool(new EdgeNodeTool(controller)); break; }
			case CONFIG   : { controller.switchConfigDialog(); break; }
			case HELP     : { controller.showHelp(HelpViewer.HELP_INDEX); break; }
		}*/
	}
	public void itemStateChanged(ItemEvent e) {
		//controller.zoomTo(zoom.getSelectedIndex());
	}
}